﻿#region Using

using System;
using Vk.Methods.Users;

#endregion

namespace Vk.Methods.Messages
{
    /// <summary>
    ///     Результат метода messages.searchDialogs
    /// </summary>
    public class DialogSearchItem
    {
        /// <summary>
        ///     Тип обьекта
        /// </summary>
        public string ItemType { get; set; }

        /// <summary>
        ///     Значение
        /// </summary>
        public object Value { get; set; }

        /// <summary>
        ///     Тип значения
        /// </summary>
        public Type ValueType { get; set; }

        public DialogSearchItem(ApiNode node)
        {
            var type = node.SelectNode("type");
            if (type == null)
                return;
            ItemType = type.String();
            switch (ItemType)
            {
                case "profile":
                    Value = new User(node);
                    ValueType = typeof(User);
                    break;
                case "chat":
                    Value = new ChatInfo(node);
                    ValueType = typeof(ChatInfo);
                    break;
            }
        }
    }
}